import React, { Component } from "react";
import { connect } from "react-redux";
// 获取当前用户的角色名称，如：管理员
// 调用高阶组件的时候，传入一个数组，如:['超级管理员','管理员']
export const Auth = (Comp, roleList) => {
  class Wrapper extends Component {
    render() {
      console.log("高阶组件获取的用户信息", this.props.user, roleList);
      let { name } = this.props.user.userInfo;
      return <>{roleList.includes(name) ? Comp : ""}</>;
    }
  }
  return connect(({ user }) => ({ user }))(Wrapper);
};
